package com.lagou.mapper;

import com.lagou.pojo.Role;
import org.apache.ibatis.annotations.CacheNamespace;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.cache.impl.PerpetualCache;
import org.mybatis.caches.redis.RedisCache;

//@CacheNamespace(implementation = PerpetualCache.class) // 开启MyBatis二级缓存
@CacheNamespace(implementation = RedisCache.class)       // 开启Redis二级缓存
public interface RoleMapper {

    @Select("select * from sys_role r,sys_user_role ur where r.id=ur.roleid and ur.userid=#{uid}")
    Role findByUid(int uid);

    @Select("select * from sys_role where id=#{id}")
    Role findById(int id);

    @Update("update sys_role set rolename=#{rolename},roleDesc=#{roleDesc} where id=#{id}")
    void update(Role role);
}
